﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class StatisticPage_Student : System.Web.UI.Page
{
    public static STUDENT_Datas myStudent_Datas = new STUDENT_Datas();     // 位置待定  // 这里定义为static 即只开辟一个即可

    protected void Page_Load(object sender, EventArgs e)
    {
        if (false == Page.IsPostBack)                               // 第一次执行
        {
            
        }

        myStudent_Datas.sStudent_ID = "0712600";                    // 该值应该由前页传入！！！位置待定 // 该句不能放入↑？

        //this.TextBox_Semester.Text = null;                        //！！！ 这里不能置空 因为每次点击按钮刷新页面时都会调用该函数
    }

    //////////////////////////////////////////////////////////////////////////////////////
    //
    //  统计总学分，平均学分绩（所有学期）
    //
    //////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Button_Credits_Click()  [统计总学分 函数]
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_Credits_Click(object sender, EventArgs e)
    {
        if (-1 == myStudent_Datas.nCredits)// 说明此时未赋值
        {
            this.Label1.Text = "aaaaaaaaaaaa";
            STUDENT_Operator myStudent_Operator = new STUDENT_Operator();

            if (false == myStudent_Operator.Statistic_Credits_GradeCredits(myStudent_Datas))
            {
                this.Label_Credits.Text = "Wrong";
                return;
            }
        }

        this.Label_Credits.Text = myStudent_Datas.nCredits.ToString().Trim();
    }

    /// <summary>
    /// Button_GradeCredits_Average_Click() [统计平均学分绩 函数]
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_GradeCredits_Average_Click(object sender, EventArgs e)
    {
        if (-1 == myStudent_Datas.nCredits)// 说明此时未赋值
        {
            this.Label1.Text = "fffffffffffffffff";
            STUDENT_Operator myStudent_Operator = new STUDENT_Operator();

            if (false == myStudent_Operator.Statistic_Credits_GradeCredits(myStudent_Datas))
            {
                this.Label_GradeCredits_Average.Text = "Wrong";
                return;
            }
        }

        this.Label_GradeCredits_Average.Text = myStudent_Datas.nGradeCredits_Average.ToString().Trim();
    }



    //////////////////////////////////////////////////////////////////////////////////////
    //
    //  统计总学分，平均学分绩（依据用户选择，针对某一学期）
    //
    //////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Button_Credits_Semester_Click() [统计总学分（按某一学期） 函数]
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_Credits_Semester_Click(object sender, EventArgs e)
    {
        // 当判定TextBox为空时 这样判定
        // 
        if ((this.TextBox_Semester.Text == "") || (this.TextBox_Semester.Text == null))
        {
            Alert("请输入要查询的学期");
            return;
        }

        STUDENT_Operator myStudent_Operator = new STUDENT_Operator();

        if (false == myStudent_Operator.Statistic_Credits_GradeCredits(myStudent_Datas,this.TextBox_Semester.Text.Trim()))
        {
            this.Label_Credits_Semester.Text = "Wrong";
            return;
        }

        this.Label_Credits_Semester.Text = myStudent_Datas.nCredits_Semester.ToString().Trim();

    }

    /// <summary>
    /// Button_GradeCredits_Average_Semester_Click()    [统计平均学分绩（按某一学期） 函数]
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_GradeCredits_Average_Semester_Click(object sender, EventArgs e)
    {
        if ((this.TextBox_Semester.Text == "") || (this.TextBox_Semester.Text == null))
        {
            Alert("请输入要查询的学期");
            return;
        }

        STUDENT_Operator myStudent_Operator = new STUDENT_Operator();

        if (false == myStudent_Operator.Statistic_Credits_GradeCredits(myStudent_Datas,this.TextBox_Semester.Text.Trim()))
        {
            this.Label_GradeCredits_Average_Semester.Text = "Wrong";
            return;
        }

        this.Label_GradeCredits_Average_Semester.Text = myStudent_Datas.nGradeCredits_Average_Semester.ToString().Trim();
    }




    /// <summary>
    /// Alert()     [错误信息提示 函数]
    /// </summary>
    /// <param name="message"></param>
    void Alert(string message)
    {
        Response.Write("<script>alert('" + message + "')</script>");
    }

}
